package com.wujunshen.algorithm.leetcode.basic;

/**
 * @author frank woo(吴峻申) <br>
 *     email:<a href="mailto:frank_wjs@hotmail.com">frank_wjs@hotmail.com</a> <br>
 * @date 2022/7/25 01:12<br>
 */
public class 按奇偶排序数组 {
  public int[] sortArrayByParity(int[] nums) {
    for (int i = 0, j = 0; j < nums.length; j++) {
      if (nums[j] % 2 == 0) {
        int temp = nums[i];
        nums[i++] = nums[j];
        nums[j] = temp;
      }
    }
    return nums;
  }
}
